package cn.xugongwei.microservicecommon.dao;

import cn.xugongwei.microservicecommon.entity.UserEntity;

import java.util.ArrayList;
import java.util.List;

/**
 * @author xugongwei (isxugongwei(a)gmail.com)
 * @version 1.0
 * @date 2019/4/10 12:02
 */
public class UserDao {

    private static final List<UserEntity> USER_LIST = new ArrayList<>();

    static {
        USER_LIST.add(new UserEntity(1, "张三", "北京"));
        USER_LIST.add(new UserEntity(2, "李四", "深圳"));
        USER_LIST.add(new UserEntity(3, "王五", "广州"));
        USER_LIST.add(new UserEntity(4, "赵六", "柳州"));
    }

    public static List<UserEntity> getList() {
        return USER_LIST;
    }

    public static UserEntity getUserById(Integer id) {
        for (UserEntity userEntity : USER_LIST) {
            if (id.equals(userEntity.getId())) {
                return userEntity;
            }
        }
        return null;
    }
}
